﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;

namespace Modles.Models;

public partial class VideoPlatformDbContext : DbContext
{
    public VideoPlatformDbContext()
    {
    }

    public VideoPlatformDbContext(DbContextOptions<VideoPlatformDbContext> options)
        : base(options)
    {
    }

    public virtual DbSet<Barrage> Barrages { get; set; }

    public virtual DbSet<Carousel> Carousels { get; set; }

    public virtual DbSet<CarouselTwo> CarouselTwos { get; set; }

    public virtual DbSet<Collection> Collections { get; set; }

    public virtual DbSet<Comment> Comments { get; set; }

    public virtual DbSet<CommentsLike> CommentsLikes { get; set; }

    public virtual DbSet<CommentsReply> CommentsReplies { get; set; }

    public virtual DbSet<Concern> Concerns { get; set; }

    public virtual DbSet<Dynamic> Dynamics { get; set; }

    public virtual DbSet<Image> Images { get; set; }

    public virtual DbSet<SearchForRecord> SearchForRecords { get; set; }

    public virtual DbSet<User> Users { get; set; }

    public virtual DbSet<UserInfo> UserInfos { get; set; }

    public virtual DbSet<Video> Videos { get; set; }

    public virtual DbSet<VideoForward> VideoForwards { get; set; }

    public virtual DbSet<VideoHistory> VideoHistories { get; set; }

    public virtual DbSet<VideoInfo> VideoInfos { get; set; }

    public virtual DbSet<VideoLike> VideoLikes { get; set; }

    public virtual DbSet<VideoType> VideoTypes { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
        => optionsBuilder.UseSqlServer("server=8.138.226.91;database=VideoPlatformDB;uid=sa;pwd=123;TrustServerCertificate=True");

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Barrage>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__barrage__3214EC0771C9B9D0");

            entity.ToTable("barrage");

            entity.Property(e => e.BarrageText).HasMaxLength(50);
        });

        modelBuilder.Entity<Carousel>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__carousel__3214EC07E3F2E3C0");

            entity.ToTable("carousel");
        });

        modelBuilder.Entity<CarouselTwo>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__carousel__3214EC0757A8B9F6");

            entity.ToTable("carouselTwo");
        });

        modelBuilder.Entity<Collection>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__collecti__3214EC07E0D4EDE6");

            entity.ToTable("collection");
        });

        modelBuilder.Entity<Comment>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__comments__3214EC07CE1ACAE7");

            entity.ToTable("comments");

            entity.Property(e => e.Content).HasMaxLength(500);
            entity.Property(e => e.Time).HasColumnType("datetime");
        });

        modelBuilder.Entity<CommentsLike>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__comments__3214EC072DC53F38");

            entity.ToTable("commentsLike");
        });

        modelBuilder.Entity<CommentsReply>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__comments__3214EC07D5B56745");

            entity.ToTable("commentsReply");

            entity.Property(e => e.Content).HasMaxLength(500);
            entity.Property(e => e.Time).HasColumnType("datetime");
        });

        modelBuilder.Entity<Concern>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__concern__3214EC07D176A191");

            entity.ToTable("concern");
        });

        modelBuilder.Entity<Dynamic>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__dynamic__3214EC07E93AAC27");

            entity.ToTable("dynamic");

            entity.Property(e => e.DynamicText).HasMaxLength(800);
            entity.Property(e => e.Time).HasColumnType("datetime");
        });

        modelBuilder.Entity<Image>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__image__3214EC0755C81D95");

            entity.ToTable("image");

            entity.Property(e => e.Address).HasMaxLength(200);
            entity.Property(e => e.Description).HasMaxLength(200);
        });

        modelBuilder.Entity<SearchForRecord>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__searchFo__3214EC07A6DA3AE0");

            entity.ToTable("searchForRecords");

            entity.Property(e => e.Frequency).HasDefaultValue(1);
            entity.Property(e => e.Recording).HasMaxLength(200);
        });

        modelBuilder.Entity<User>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__user__3214EC07DD4B1C9A");

            entity.ToTable("user");

            entity.HasIndex(e => e.Account, "UQ__user__B0C3AC464BC18F1D").IsUnique();

            entity.Property(e => e.Account).HasMaxLength(20);
            entity.Property(e => e.Password).HasMaxLength(50);
        });

        modelBuilder.Entity<UserInfo>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__userInfo__3214EC07D68A631D");

            entity.ToTable("userInfo");

            entity.Property(e => e.Afos)
                .HasDefaultValue(0)
                .HasColumnName("AFOS");
            entity.Property(e => e.Avatar)
                .HasMaxLength(200)
                .HasDefaultValue("#");
            entity.Property(e => e.Name).HasMaxLength(50);
            entity.Property(e => e.Region)
                .HasMaxLength(20)
                .IsUnicode(false)
                .IsFixedLength();
            entity.Property(e => e.Signature).HasMaxLength(200);
        });

        modelBuilder.Entity<Video>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__video__3214EC07C0C2308A");

            entity.ToTable("video");

            entity.Property(e => e.Address).HasMaxLength(200);
        });

        modelBuilder.Entity<VideoForward>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__videoFor__3214EC07A2F8CA80");

            entity.ToTable("videoForward");
        });

        modelBuilder.Entity<VideoHistory>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__videoHis__3214EC074B00EAA4");

            entity.ToTable("videoHistory");

            entity.Property(e => e.DateTime).HasColumnType("datetime");
        });

        modelBuilder.Entity<VideoInfo>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__videoInf__3214EC07E4F9EDF1");

            entity.ToTable("videoInfo");

            entity.Property(e => e.Briefintroduction)
                .HasMaxLength(200)
                .IsUnicode(false)
                .IsFixedLength();
            entity.Property(e => e.Label).HasMaxLength(400);
            entity.Property(e => e.Time).HasColumnType("datetime");
            entity.Property(e => e.Title)
                .HasMaxLength(40)
                .IsUnicode(false)
                .IsFixedLength();
        });

        modelBuilder.Entity<VideoLike>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__videoLik__3214EC0736A806B7");

            entity.ToTable("videoLike");
        });

        modelBuilder.Entity<VideoType>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__videoTyp__3214EC07603D642B");

            entity.ToTable("videoType");

            entity.Property(e => e.Type).HasMaxLength(20);
        });

        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
